<?php

class Client
{
    private $eventBase;
    private $client;
    private $what;
    private $events;

    public function __construct(
        $eventBase,
        $client,
        $what,
        &$events
    )
    {
        echo '3323';
        $this->eventBase = $eventBase;
        $this->client = $client;
        $this->what = $what;
        $this->events = $events;
    }

    public function handle()
    {

        $event = new Event(
            $this->eventBase,
            $this->client,
            $this->what,
            function ($client) {
                fwrite($client, '我爱你，小萍萍' . PHP_EOL);

                print_r(fread($client, 1024));

                fclose($client);

                ($this->events[(int) $client][$this->what])->free();
            });

        $event->add();

        $this->events[(int) $this->client][$this->what] = $event;
    }
}

